//
export interface reportObjectData {
    key: string;
    obj: object;
}

//
export interface ConstReportType {
    key: string;
    data: string[];
}

//拉取激励视频请求
export const LOAD_VIDEO: ConstReportType = {
    key: 'loadVideo',
    data: ['source'],
}

//成功爆光激励视频
export const SHOW_VIDEO: ConstReportType = {
    key: 'showVideo',
    data: ['source'],
}

//提前关闭激励视频
export const BEFORE_CLOSE_VIDEO: ConstReportType = {
    key: 'beforeCloseVideo',
    data: ['source'],
}

//成功观看激励视频
export const LOOK_VIDEO: ConstReportType = {
    key: 'lookVideo',
    data: ['source'],
}

//分享录屏
export const SHARE_GAME_RECORD: ConstReportType = {
    key: 'shareGameRecord',
    data: ['explain'],
}

//激励视频派发失败 拉取分享获得奖励
export const LOOK_VIDEO_FAIL_TO_SHARE: ConstReportType = {
    key: 'lookVideoFailToShare',
    data: ['explain']
}

//激励视频错误
export const VIDEO_FAIL_LOAD_OR_SHOW: ConstReportType = {
    key: 'videoFailLoadOrShow',
    data: ['code', 'msg'],
}

//添加桌面事件
export const ADD_SHORTCUT: ConstReportType = {
    key: 'addShortcut',
    data: ['explain']
}

//获取 拉取广告 上报对象
export function getLoadVideoReportData(properties: string[] | string): reportObjectData {
    return getReportObjectData(LOAD_VIDEO, properties);
}

//获取 展示广告 上报对象
export function getShowVideoReportData(properties: string[] | string): reportObjectData {
    return getReportObjectData(SHOW_VIDEO, properties);
}

//获取 提前关闭 上报对象
export function getBeforeCloseVideoReportData(properties: string[] | string): reportObjectData {
    return getReportObjectData(BEFORE_CLOSE_VIDEO, properties);
}

//获取 成功观看激励视频 上报对象
export function getLookVideoReportData(properties: string[] | string): reportObjectData {
    return getReportObjectData(LOOK_VIDEO, properties);
}

//获取 分享录屏 上报对象
export function getShareGameRecordReportData(properties: string[] | string): reportObjectData {
    return getReportObjectData(SHARE_GAME_RECORD, properties);
}

//获取 激励失败派发失败拉取分享获得奖励
export function getLookVideoFailShareReportData(properties: string[] | string): reportObjectData {
    return getReportObjectData(LOOK_VIDEO_FAIL_TO_SHARE, properties);
}

//获取 添加桌面
export function getAddShortcutReportData(properties: string[] | string): reportObjectData {
    return getReportObjectData(ADD_SHORTCUT, properties);
}

//获取 加载或展示激励视频失败
export function getVideoFailLoadOrShow(properties: string[] | string): reportObjectData {
    return getReportObjectData(VIDEO_FAIL_LOAD_OR_SHOW, properties);
}

function getReportObjectData(srcType: ConstReportType, properties: string[] | string): reportObjectData {
    let strings: string[] = [];
    if (typeof properties == 'string') {
        strings = [properties];
    } else {
        strings = [].concat(properties);
    }
    let obj = <reportObjectData>{};
    //key
    obj.key = srcType.key;
    obj.obj = {};
    //data
    for (let k in srcType.data) {
        let key = srcType.data[k];
        obj.obj[key] = strings.shift();
    }
    return obj;
}













